﻿namespace Simple.Services.System.Log.Models
{
    public class LoginLogModel : ModelBase
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid? Id { get; set; }

        /// <summary>
        /// 操作人
        /// </summary>
        [MaxLength(64)]
        public string? Account { get; set; }

        /// <summary>
        /// 登录来源
        /// </summary>
        /// 0:网页，1:小程序
        public int? LoginSource { get; set; }

        /// <summary>
        /// 登录类型
        /// </summary>
        /// 0:登录，1:登出
        public int? LoginType { get; set; }

        /// <summary>
        /// 浏览器
        /// </summary>
        [MaxLength(512)]
        public string? Browser { get; set; }

        /// <summary>
        /// 操作系统
        /// </summary>
        public string? OperatingSystem { get; set; }

        /// <summary>
        /// IP
        /// </summary>
        [MaxLength(32)]
        public string? Ip { get; set; }

        /// <summary>
        /// IP所在地区
        /// </summary>
        [MaxLength(100)]
        public string? IpArea { get; set; }

        /// <summary>
        /// 是否执行成功
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// 返回结果
        /// </summary>
        public string? Result { get; set; }

        /// <summary>
        /// 耗时（毫秒）
        /// </summary>
        public long? ElapsedTime { get; set; }

        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime OperatingTime { get; set; }

        public override void ConfigureMapper(Profile profile)
        {
            profile.CreateMap<SysLoginLogs, LoginLogModel>()
                 .ForMember(d => d.OperatingTime, options => options.MapFrom(s => s.OperatingTime.LocalDateTime));
        }
    }
}
